package com.linkhub.oms.component.transactional.service.impl;

import com.linkhub.oms.common.annotation.AfterCommit;
import com.linkhub.oms.common.util.QtAopUtil;
import com.linkhub.oms.component.transactional.service.TransactionalCallBackService;
import org.springframework.stereotype.Service;

import java.util.function.Consumer;

/**
 * @Description: 事务回调服务
 * @Author: echo
 * @Date: 2021/3/15 18:54
 * @Version: 1.0
 */
@Service
@SuppressWarnings("all")
public class TransactionalCallBackServiceImpl implements TransactionalCallBackService {
    @Override
    @AfterCommit(async = false)
    public <T> void syncHandleAfterCommit(T service, Consumer<T> consumer) {
        consumer.accept(QtAopUtil.getProxyObject(service));
    }

    @Override
    @AfterCommit
    public <T> void asyncHandleAfterCommit(T service, Consumer<T> consumer) {
        consumer.accept(QtAopUtil.getProxyObject(service));
    }

}
